<extend name="Public:base"/>

<block name="content">

    <div class="feeldesk-form pd0">

		<form action="" class="layui-form" method="post" enctype="multipart/form-data">

		<div class="layui-tab">

            <ul class="layui-tab-title">

                <li class="layui-this">{:L('ADD_CUSTOMER')}</li>

				<div class="form-submit">

					<a href="javascript:" class="layui-btn layui-btn-normal submitForm">{:l('SUBMIT')}</a>

					<notempty name="wechat">

					<a href="javascript:closeLayerOpen();" class="layui-btn layui-btn-normal titleCancel">{:l('CANCEL')}</a>

					<div class="clear"></div>

					</notempty>

				</div>

            </ul>

        </div>

        <!--<div class="form-nav">

            <ul>

                <li><a href="javascript:" onclick="switchtab(this,1);" class="form-tab active">{:L('BASIC_INFORMATION')}</a></li>

                <li><a href="javascript:" onclick="switchtab(this,2);" class="form-tab">{:L('PRIMARY_CONTACT')}</a></li>

            </ul>

        </div>-->
		<php>
			$t = 0;
			$ft = 0;
			$reg = 0;
		</php>
        <div class="form-content form-content1 wd100 fl">

                <div class="form-item pb25 pt50">

					<div class="layui-form-item">

						<label class="layui-form-label">

						   {:L('CUSTOMER_RESPONSIBLE')}

						</label>

						<div class="layui-input-inline">

							<select name="customer[member_id]" lay-ignore id="select2">

								<option value="">{:L('CHOOSE')}{:L('CUSTOMER_RESPONSIBLE')}</option>

								<volist name="members" id="v">

									<option value="{$v.member_id}" <empty name="type"><eq name="thisMember.member_id" value="$v.member_id" >selected</eq></empty>>{$v.name}</option>

								</volist>

							</select>

							<script>

								$("#select2").select2();

							</script>

						</div>

						<i class="layui-icon layui-icon-about intro-icon" data-note="{:L('ENTER_NAME_SEARCH')}"></i>

					</div>

                    <input type="hidden" name="customer[from_type]" value="{$fromType}"/>

                    <input type="hidden" name="customer[originalId]" value="{$apiData.originalId}"/>

					<if condition="$crmsite['customerReseller'] == 1">

						<div class="layui-form-item">

							<label class="layui-form-label">

								<span class="red">*</span>

							   {:L('CUSTOMER_TYPE')}

							</label>

							<div class="layui-input-inline">

								<input type="radio" name="customer[customer_type]" value="customer" checked title="{:L('ORDINARY_CUSTOMER')}">

								<input type="radio" name="customer[customer_type]" value="agent" title="{:L('DEALER')}">

							</div>

						</div>

					</if>

                       <volist name="customerform" id="vo">

                       <!-- 字段未设置查看范围或当前用户角色在查看范围内 -->
                       <if condition="!$vo['role_id'] || in_array($index['role_id'],explode(',',$vo['role_id']))">

                        <div class="layui-form-item">

                            <label class="layui-form-label">

                                <eq name="vo.is_required" value="0"><span class="red">*</span> </eq>

                                {$vo.form_description}

                            </label>

							<eq name="vo.form_type" value="region">

								<php>
									$reg++;
								</php>


								{:W('Region/getRegion',['customer_form',$vo['form_name'],$reg])}

							<else/>

                            <div class="layui-input-inline">

                                <eq name="vo.form_type" value="text">

                                    <!-- 单行文本框 -->
                                    <input type="text" name="customer_form[{$vo.form_name}]" value="{$customerData[$vo['form_name']]}" placeholder="" class="layui-input">

                                </eq>

								 <eq name="vo.form_type" value="phone">

                                    <!-- {:L('CELL_PHONE')} -->
                                    <input type="text" onKeyPress="if (event.keyCode!=46 && event.keyCode!=45 && event.keyCode<48 || event.keyCode>57) event.returnValue=false" name="customer_form[{$vo.form_name}]" value="{$customerData[$vo['form_name']]}" placeholder="" class="layui-input">

                                </eq>

								 <eq name="vo.form_type" value="email">

                                    <!-- {:L('MAILBOX')} -->
                                    <input type="text" name="customer_form[{$vo.form_name}]" value="{$customerData[$vo['form_name']]}" placeholder="" class="layui-input">

                                </eq>

								 <eq name="vo.form_type" value="number">

                                    <!-- {:L('DIGITAL')} -->
                                    <input type="number" onKeyPress="if (event.keyCode!=46 && event.keyCode!=45 && event.keyCode<48 || event.keyCode>57) event.returnValue=false" name="customer_form[{$vo.form_name}]" placeholder="" class="layui-input">

                                </eq>

								<eq name="vo.form_type" value="decimal">

                                    <!-- 小数 -->
                                    <input type="text" name="customer_form[{$vo.form_name}]" placeholder="" class="layui-input">

                                </eq>

                                <eq name="vo.form_type" value="select">

                                    <!-- 下拉菜单 -->
                                    <select name="customer_form[{$vo.form_name}]">

                                        <option value="">{$vo.form_description}</option>

                                        <foreach name="vo.option" item="op">

                                            <option value="{$op}">{$op}</option>

                                        </foreach>

                                    </select>

                                </eq>

                                <eq name="vo.form_type" value="select_text">

                                    <php>
                                        $st++;
                                    </php>
                                    <!-- 下拉填写 -->
                                    {:W('Update/selectTextForm',['customer',$vo,$st])}

                                </eq>

                                <!-- 时间控件 -->
                                <eq name="vo.form_type" value="date">

									<php>
										$ft++;
									</php>

                                    <input type='text' name="customer_form[{$vo.form_name}]" class="layui-input cursor layui-form-time" id="form_time<php>echo $ft;</php>" placeholder="{:L('SELECT_TIME')}" >

                                </eq>


                                <eq name="vo.form_type" value="checkbox">

                                    <!-- 复选框 -->
                                    <volist name="vo.option" id="op">

                                        <input type="checkbox" name="customer_form[{$vo.form_name}][]" lay-skin="primary" title="{$op}" value="{$op}">

                                    </volist>

                                </eq>

                                <eq name="vo.form_type" value="radio">

                                    <!-- 单选框-->
                                    <volist name="vo.option" id="op">

                                        <input type="radio" name="customer_form[{$vo.form_name}]" value="{$op}" title="{$op}">

                                    </volist>

                                </eq>

                                <!-- 文本域 -->
                                <eq name="vo.form_type" value="textarea">

									<php>
										$t++
									</php>

                                    <textarea class="layui-textarea layui-hide ticket-textarea" name="customer_form[{$vo.form_name}]" id="ticketEditor<php>echo $t;</php>"></textarea>

                                </eq>

                            </div>

							</eq>

                            <notempty name="vo.form_explain">

                                <i class="layui-icon layui-icon-about intro-icon" data-note="{$vo.form_explain}"></i>

                            </notempty>

                        </div>

                       </if>

                    </volist>

				</div>

        </div>

		<div class="form-content form-content2 wd50 fr hidden">

			<div class="form-item pt50 pb25 create-both-end">

                   <volist name="contacterform" id="vo">

                   <!-- 字段未设置查看范围或当前用户角色在查看范围内 -->
                   <if condition="!$vo['role_id'] || in_array($index['role_id'],explode(',',$vo['role_id']))">

                        <div class="layui-form-item">

                            <label class="layui-form-label">

                                <eq name="vo.is_required" value="0"><span class="red">*</span> </eq>

                                {$vo.form_description}

                            </label>

							<eq name="vo.form_type" value="region">

								<php>
									$reg++;
								</php>

								{:W('Region/getRegion',['contacter_form',$vo['form_name'],$reg])}

							<else/>

                            <div class="layui-input-inline">

                                <eq name="vo.form_type" value="text">
									<!-- 单行文本框 -->
									<eq name="vo.form_name" value="wechat">

										<notempty name="wechat">

											<input type="text" name="contacter_form[{$vo.form_name}]" value="{$wechat}" readonly placeholder="" class="layui-input">

										<else/>

											<input type="text" name="contacter_form[{$vo.form_name}]" value="{$contacterData[$vo['form_name']]}" placeholder="" class="layui-input">

										</notempty>

									<else/>

										<input type="text" name="contacter_form[{$vo.form_name}]" value="{$contacterData[$vo['form_name']]}" placeholder="" class="layui-input">

									</eq>

                                </eq>

								 <eq name="vo.form_type" value="phone">

                                    <!-- {:L('CELL_PHONE')} -->
                                    <input type="text" onKeyPress="if (event.keyCode!=46 && event.keyCode!=45 && event.keyCode<48 || event.keyCode>57) event.returnValue=false" name="contacter_form[{$vo.form_name}]" value="{$contacterData[$vo['form_name']]}" placeholder="" class="layui-input">

                                </eq>

								 <eq name="vo.form_type" value="email">

                                    <!-- {:L('MAILBOX')} -->
                                    <input type="text" name="contacter_form[{$vo.form_name}]" value="{$contacterData[$vo['form_name']]}" placeholder="" class="layui-input">

                                </eq>

								 <eq name="vo.form_type" value="number">

                                    <!-- {:L('DIGITAL')} -->
                                    <input type="number" onKeyPress="if (event.keyCode!=46 && event.keyCode!=45 && event.keyCode<48 || event.keyCode>57) event.returnValue=false" name="contacter_form[{$vo.form_name}]" placeholder="" class="layui-input">

                                </eq>

								<eq name="vo.form_type" value="decimal">

                                    <!-- 小数 -->
                                    <input type="text" name="contacter_form[{$vo.form_name}]" placeholder="" class="layui-input">

                                </eq>

                                <eq name="vo.form_type" value="select">

                                    <!-- 下拉菜单 -->
                                    <select name="contacter_form[{$vo.form_name}]">

                                        <option value="">{$vo.form_description}</option>

                                        <foreach name="vo.option" item="op">

                                            <option value="{$op}">{$op}</option>

                                        </foreach>

                                    </select>

                                </eq>
								
								<eq name="vo.form_type" value="select_text">

                                    <php>
                                        $st++;
                                    </php>
                                    <!-- 下拉填写 -->
                                    {:W('Update/selectTextForm',['contacter',$vo,$st])}

                                </eq>

                                <!-- 时间控件 -->
                                <eq name="vo.form_type" value="date">

									<php>
										$ft++;
									</php>

                                    <input type='text' name="contacter_form[{$vo.form_name}]" class="layui-input cursor layui-form-time" id="form_time<php>echo $ft;</php>" placeholder="{:L('SELECT_TIME')}" >

                                </eq>

                                <eq name="vo.form_type" value="checkbox">

                                    <!-- 复选框 -->
                                    <volist name="vo.option" id="op">

                                        <input type="checkbox" name="contacter_form[{$vo.form_name}][]" lay-skin="primary" title="{$op}" value="{$op}">

                                    </volist>

                                </eq>

                                <eq name="vo.form_type" value="radio">

                                    <!-- 单选框-->
                                    <volist name="vo.option" id="op">

                                        <input type="radio" name="contacter_form[{$vo.form_name}]" value="{$op}" title="{$op}">

                                    </volist>

                                </eq>

                                <!-- 文本域 -->
                                <eq name="vo.form_type" value="textarea">

									<php>
										$t++
									</php>

                                    <textarea class="layui-textarea layui-hide ticket-textarea" name="contacter_form[{$vo.form_name}]" id="ticketEditor<php>echo $t;</php>"></textarea>

                                </eq>

                            </div>

							</eq>

                            <notempty name="vo.form_explain">

                                <i class="layui-icon layui-icon-about intro-icon" data-note="{$vo.form_explain}"></i>

                            </notempty>

                        </div>

                    </if>

                    </volist>

				</div>

		</div>

		<div class="clear"></div>

		</form>

    </div>

    <include file="Public:language" />



    <script type="text/javascript">

        $("#choose").hide();

        layui.use('form',function()
        {
            var form = layui.form;

            form.on('select(form_type)', function(data)
            {
                var type = data.value;

                if(type == 'radio' || type == 'checkbox' || type == 'select')
                {
                    $("#choose").slideDown(300);
                }
                else
                {
                    $("#choose").slideUp(300);
                }
            });
        })

    </script>

</block>
